﻿using System;
using System.Collections.Generic;
using Discuz.Common;
using Discuz.Forum;
using Discuz.Entity;
using System.Data;
using Discuz.Config;


namespace Discuz.Web
{
    public class PoliticsPlatform : Discuz.Forum.PageBase
    {
        public int forumid = 2;
        public ForumInfo forum;

        private string condition = ""; //查询条件

        private string orderStr = "";//排序方式

        /// <summary>
        /// 排序方向
        /// </summary>
        public int direct = DNTRequest.GetInt("direct", 1); //排序方向[默认：降序]  

        /// <summary>
        /// 论坛相对根的路径
        /// </summary>
        public string forumpath = BaseConfigs.GetForumPath;

        public List<TopicInfo> topiclist;

        protected override void ShowPage()
        {

            topiclist = GetTopicInfoList(5, 1, 0);
            //int i = topicList.Rows.Count;

        }


        /// <summary>
        /// 获取主题信息列表
        /// </summary>
        /// <param name="pageSize">页面大小</param>
        /// <param name="pageIndex">当前页</param>
        /// <param name="startNumber">置顶帖数量</param>
        /// <returns></returns>
        public List<TopicInfo> GetTopicInfoList(int pageSize, int pageIndex, int startNumber)
        {

            forum = Forums.GetForumInfo(2);
            List<TopicInfo> topicList = new List<TopicInfo>();
            if (orderStr == "" && direct == 1)
            {
                topicList = Topics.GetTopicList(forumid, pageSize, pageIndex, startNumber, 600, config.Hottopic, forum.Autoclose,
                                                    forum.Topictypeprefix, condition);
            }
            else
            {
                if (direct == 0 && orderStr == string.Empty)
                    orderStr = "lastpostid";

                topicList = Topics.GetTopicList(forumid, pageSize, pageIndex, startNumber, 600, config.Hottopic, forum.Autoclose,
                                                forum.Topictypeprefix, condition, orderStr, direct);
            }
            return topicList;
        }

    }
}
